// 客户模糊查询
import React from 'react';
import { Select, Spin } from 'antd';
import { connect } from 'dva';
import HOCSelect from '@/components/AntDesign/Select';

const { Option } = Select;

@connect(({ publicdata: { accoOwnerList }, loading }) => ({
  accoOwnerList,
  loading: loading.effects['publicdata/fetchOsAccoList'],
}))
class Customer extends React.Component {
  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'publicdata/fetchOsAccoList',
      payload: {},
    });
  }

  render() {
    const { accoOwnerList = [], loading } = this.props;
    console.log(accoOwnerList, 'accoOwnerList');
    return (
      <HOCSelect
        placeholder="请输入关键字检索"
        {...this.props}
        showSearch
        optionFilterProp="children"
        showArrow={false}
        notFoundContent={loading ? <Spin size="small" /> : null}
      >
        {accoOwnerList.map(item => (
          <Option key={item.userId} title={item.userName} fsOptions={item}>
            {item.userName}
          </Option>
        ))}
      </HOCSelect>
    );
  }
}
export default Customer;
